package worktest.volitale;

/**
 * 测试volitale
 * @author Administrator
 *
 */
public class MyThread implements  Runnable {
	
	private int count = 1;

	private void setCount(int count) {
		this.count = count;
	}
	
	public void run(){
		System.out.println("********进入run方法");
		while (count == 1) {
			System.out.println("+++++++++++++++++++++++++++++++");//这行代码到底是什么鬼？竟然导致了线程之间变量的可见性
		}
		System.out.println("线程停止");
	}
	
	
	public static void main(String[] args) throws InterruptedException {
		MyThread mt = new MyThread();
		Thread t = new Thread(mt);
		t.start();
		
		Thread.sleep(1000);
		mt.setCount(0);
		System.out.println("线程已经被设置成了0"); 
	}
}
